<html>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<title>Exercises</title>
<link rel="STYLESHEET" type="text/css" href="images/style.css">
<link rel="STYLESHEET" type="text/css" href="images/docsafari.css">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/team.gif" width="60" height="17" border="0" align="absmiddle"  alt="Team BBL"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=ch17lev1sec7.html><img src="images/prev.gif" width="60" height="17" border="0" align="absmiddle" alt="Previous Page"></a>
<a href=ch18.html><img src="images/next.gif" width="60" height="17" border="0" align="absmiddle" alt="Next Page"></a>
</div></td></tr></table>
<br><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td valign="top"><a name="ch17lev1sec8"></a>
<h3 class="docSection1Title">Exercises</h3>
<P><table border="0" cellspacing="16" cellpadding="0"><TR valign="top"><td align="right" class="docText" width="50"><a name="ch17qa1q1"></a><B>17.1</b></TD><TD><p class="docText">Recode <a class="docLink" href="ch17lev1sec2.html#ch17fig04">Figure 17.4</a> to use the standard I/O library instead of <tt>read</tt> and <tt>write</tt> on the STREAMS pipe.</p></TD></TR><TR valign="top"><td align="right" class="docText" width="50"><a name="ch17qa1q2"></a><B>17.2</b></td><TD><p class="docText">Write the following program using the file descriptor passing functions from this chapter and the parentchild synchronization routines from <a class="docLink" href="ch08lev1sec9.html#ch08lev1sec9">Section 8.9</a>. The program calls <tt>fork</tt>, and the child <tt>open</tt>s an existing file and passes the open descriptor to the parent. The child then positions the file using <tt>lseek</tt> and notifies the parent. The parent reads the file's current offset and prints it for verification. If the file was passed from the child to the parent as we described, they should be sharing the same file table entry, so each time the child changes the file's current offset, that change should also affect the parent's descriptor. Have the child position the file to a different offset and notify the parent again.</P></TD></tr><TR valign="top"><TD align="right" class="docText" width="50"><a name="ch17qa1q3"></a><b><a class="docLink" href="app03lev1sec17.html#ch17qa1q3a1">17.3</a></b></TD><TD><p class="docText">In <a class="docLink" href="ch17lev1sec5.html#ch17fig29">Figures 17.29</a> and <a class="docLink" href="ch17lev1sec5.html#ch17fig30">17.30</a>, we differentiated between declaring and defining the global variables. What is the difference?</p></td></tr><tr valign="top"><TD align="right" class="docText" width="50"><a name="ch17qa1q4"></a><b>17.4</b></TD><td><p class="docText">Recode the <tt>buf_args</tt> function (<a class="docLink" href="ch17lev1sec5.html#ch17fig32">Figure 17.32</a>), removing the compile-time limit on the size of the <tt>argv</tt> array. Use dynamic memory allocation.</P></td></tr><tr valign="top"><td align="right" class="docText" width="50"><a name="ch17qa1q5"></a><b><a class="docLink" href="app03lev1sec17.html#ch17qa1q5a1">17.5</a></b></td><td><p class="docText">Describe ways to optimize the function <tt>loop</tt> in <a class="docLink" href="ch17lev1sec6.html#ch17fig38">Figure 17.38</a> and <a class="docLink" href="ch17lev1sec6.html#ch17fig39">Figure 17.39</a>. Implement your optimizations.</p></td></tr></table></p>

<ul></ul></td></tr></table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/team.gif" width="60" height="17" border="0" align="absmiddle"  alt="Team BBL"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=ch17lev1sec7.html><img src="images/prev.gif" width="60" height="17" border="0" align="absmiddle" alt="Previous Page"></a>
<a href=ch18.html><img src="images/next.gif" width="60" height="17" border="0" align="absmiddle" alt="Next Page"></a>
</div></td></tr></table>
</body></html><br>
<table width="100%" cellspacing="0" cellpadding="0"
style="margin-top: 0pt; border-collapse: collapse;"> 
<tr> <td align="right" style="background-color=white; border-top: 1px solid gray;"> 
<a href="http://www.zipghost.com/" target="_blank" style="font-family: Tahoma, Verdana;
 font-size: 11px; text-decoration: none;">The CHM file was converted to HTM by Trial version of <b>ChmD<!--93-->ecompiler</b>.</a>
</TD>
</TR><tr>
<td align="right" style="background-color=white; "> 
<a href="http://www.etextwizard.com/download/cd/cdsetup.exe" target="_blank" style="font-family: Tahoma, Verdana;
 font-size: 11px; text-decoration: none;">Download <b>ChmDec<!--93-->ompiler</b> at: http://www.zipghost.com</a>
</TD></tr></table>
